package com.example.demo.Service.impl;

import com.example.demo.Service.ICategoryService;
import com.example.demo.Service.IProductPageService;
import com.example.demo.entity.Category;
import com.example.demo.entity.vo.ProductPageVo;
import com.example.demo.mapper.CategoryMapper;
import com.example.demo.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IProductPageServiceImpl implements IProductPageService {

    @Autowired
    private ProductMapper productMapper;


    @Override
    public List<ProductPageVo> list(Integer pageNum, Integer pageSize, Long categoryId,Long productId) {

        Integer offset = (pageNum - 1) * pageSize;
        return productMapper.page(offset,pageSize,categoryId,productId);
    }

    @Override
    public int count(Long categoryId) {
        return productMapper.count(categoryId);
    }
}
